package com.example.custcomsumer.service;

import com.example.custcomsumer.entity.CustInfo;
import com.example.custcomsumer.entity.Label;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@Service
public class CustInfoService {

    @Autowired
    private RestTemplate restTemplate;

    public List<CustInfo> selectFindBySql(int currentPage, int pageSize) {
        return restTemplate.getForObject("http://custom-info-provider/custom-provider/selectCustomBySql" + "/" + currentPage + "/" + pageSize, List.class);
    }

    public Integer getTotal() {
        return restTemplate.getForObject("http://custom-info-provider/custom-provider/getTotal", Integer.class);
    }

    public List<Label> select(int currentPage, int pageSize) {
        return restTemplate.getForObject("http://custom-info-provider/label-provider/select/" + currentPage + "/" + pageSize, List.class);
    }

    public List<Label> selectGoal(int currentPage, int pageSize) {
        return restTemplate.getForObject("http://custom-info-provider/label-provider/selectGoal/" + currentPage + "/" + pageSize, List.class);
    }

    public Integer getSelect() {
        return restTemplate.getForObject("http://custom-info-provider/label-provider/getSelect", Integer.class);
    }

    public Integer getSelectGoal() {
        return restTemplate.getForObject("http://custom-info-provider/label-provider/getSelectGoal", Integer.class);
    }

    public void setGoal(int id) {
        restTemplate.getForObject("http://custom-info-provider/label-provider/setGoal/" + id, void.class);
    }

    public void cancelGoal(int id) {
        restTemplate.getForObject("http://custom-info-provider/label-provider/cancelGoal/" + id, void.class);
    }
}
